install_driver(mysql) failed: Can't load mysql.so

chris (2007-02-21 14:01:11)
4875 views
0 replies
When mysql client libraries are missing, you'll get mysql.so errors - often followed by 'install_driver(mysql) failed: Can't load mysql.so - error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file: No such file or directory'. This all looks pretty nasty. The first thing to do is to look around for your libmysqlclient.so file to see if perhaps it's just installed in the wrong place. This might happen if you set an incorrect prefix at compile time, or if your dynamic linker doesn't know where to look for it.

Let's say that you can't find the file - what do you do next? Well first you need to download the sources and build and install the client libraries on your system. The following command dialogue explains how that is done:

root@baikal:~# ftp ftp.mysql.com
Connected to production.mysql.com.
220 Welcome to MySQL AB's FTP service
Name (ftp.mysql.com:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd pub/mysql/src
250 Directory successfully changed.
ftp> bin
200 Switching to Binary mode.
ftp> prompt
Interactive mode off.
ftp> get mysql-5.0.28.tar.gz
local: mysql-5.0.28.tar.gz remote: mysql-5.0.28.tar.gz
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for mysql-5.0.28.tar.gz (25873293 bytes).
226 File send OK.
25873293 bytes received in 55 secs (4.6e+02 Kbytes/sec)

So first you download the mysql sources.
You can then extract the source directory and start compiling:

root@baikal:~# tar -zxvf mysql-5.0.28.tar.gz
root@baikal:~# cd mysql-5.0.28
root@baikal:~# ./configure --without-server && make && make install

At this point, you're just about complete. So try running your script again (or whatever it was which was spitting out the missing libmysqlclient.so errors earlier on). If this still isn't running, then you need to check again where the library is installed and make sure that your dynamic linker can find it:

root@baikal:~# updatedb && locate libmysqlclient.so
/usr/src/mysql-5.0.28/libmysql/.libs/libmysqlclient.so
/usr/src/mysql-5.0.28/libmysql/.libs/libmysqlclient.so.15
/usr/src/mysql-5.0.28/libmysql/.libs/libmysqlclient.so.15.0.0
/usr/local/lib/mysql/libmysqlclient.so
/usr/local/lib/mysql/libmysqlclient.so.15
/usr/local/lib/mysql/libmysqlclient.so.15.0.0

Ahh - so the file is in /usr/local/lib. Now let's check the ld.so.conf to see if that location is included in the search paths for ld:

root@baikal:~# cat /etc/ld.so.conf
/usr/local/lib
/usr/X11R6/lib
/usr/i486-slackware-linux/lib
/opt/kde/lib
/usr/lib/qt/lib

It isn't! So all we need to do is add the following line to that file, then run 'ldconfig' and then try again:

/usr/local/lib/mysql <-- add this to the ld.so.conf

root@baikal:~# ldconfig

Now you should be ready to roll!!


hope that's useful


christo

comment